#include "ResultEditor.h"
#include "../core/src/container/Result.h"

namespace Xps
{
	ResultEditor::ResultEditor(QWidget *parent)
	{
		setObjectName("ResultEditor");
		QGridLayout* content_layout = new QGridLayout();
		
		setLayout(content_layout);
		
		name = new QLineEdit();
		desc = new QTextEdit();
		content_layout->addWidget(new QLabel("Name:"),0, 0);
		content_layout->addWidget(name, 0, 1);
		content_layout->addWidget(new QLabel("Description:"),1,0,1,2);
		content_layout->addWidget(desc, 2,0,1,2);
	}

	void ResultEditor::write(XpsAssets::AssetData* ad)
	{
		XpsAssets::Result* r = (XpsAssets::Result*) ad;
		
		r->setName(name->text());
		r->setDesc(desc->toPlainText());
	}

	void ResultEditor::read(XpsAssets::AssetData* ad)
	{
		XpsAssets::Result* r = (XpsAssets::Result*) ad;

		name->setText(r->name());
		desc->setText(r->desc());
	}
}